package test.netty.common.exceptions;

/**
 * <p>标题: 错误类封装</p>
 * <p>功能描述: </p>
 *
 * <p>创建时间: 2021/3/31 11:12</p>
 * <p>作者：chaiys</p>
 **/
public class NettyException extends RuntimeException {
    private static final long serialVersionUID = -6721842519553465961L;

    /**
     * 错误代码
     **/
    private String code;

    /**
     * 错误消息
     **/
    private String message;

    /*======================= 构造方法开始 =======================*/
    public NettyException() {
        this("", "", new Throwable());
    }

    public NettyException(String message) {
        this("", message, new Throwable());
    }

    public NettyException(String code, String message) {
        this(code, message, new Throwable());
    }

    public NettyException(Throwable cause) {
        this("", "", cause);
    }

    public NettyException(String message, Throwable cause) {
        this("", message, cause);
    }

    public NettyException(String code, String message, Throwable cause) {
        super("[" + code + "] - " + message, cause);
        this.message = message;
        this.code = code;
    }

    /*======================= 构造方法结束 =======================*/

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
